import { reqPostSearchInfo } from "@/api/search";

const state = {
  searchList: {},
};
const mutations = {
  GETSEARCHLIST(state, list) {
    state.searchList = list;
  },
};
const actions = {
  async getSearchList({ commit }, params = {}) {
    let res = await reqPostSearchInfo(params);
    if (res.code === 200) {
      commit("GETSEARCHLIST", res.data);
    }
  },
};
//简化数据
const getters = {
  //商品列表
  goodsList(state) {
    return state.searchList.goodsList || [];
  },
  //品牌列表
  trademarkList(state) {
    return state.searchList.trademarkList || [];
  },
  //属性列表
  attrsList(state) {
    return state.searchList.attrsList || [];
  },
};

export default {
  state,
  mutations,
  actions,
  getters,
};
